import express from 'express';
import controller from '../controllers/user.controller';
import tokenMiddleware from '../middleware/token.middleware';
import validate from '../middleware/validator.middleware';
import UserSchemas from '../schemas/user.schemas';

const router = express.Router();

router.get('/image-captcha', controller.imageCaptcha);

router.get(
    '/email-captcha',
    validate(UserSchemas.emailCaptcha),
    controller.emailCaptcha
);

router.post(
    '/register',
    validate(UserSchemas.register),
    controller.register
);

router.post(
    '/login',
    validate(UserSchemas.login),
    controller.login
);

router.get(
    '/info',
    validate(UserSchemas.getUserInfo),
    controller.getUserInfo
);

router.post(
    '/avatar',
    tokenMiddleware,
    controller.uploadAvatar
);

router.get(
    '/avatar',
    validate(UserSchemas.downloadAvatar),
    controller.downloadAvatar
);

router.put(
    '/',
    tokenMiddleware,
    validate(UserSchemas.update),
    controller.updateUser
);

router.delete(
    '/',
    tokenMiddleware,
    controller.deleteUser
);
export default router;